From 68afcbc491c40150d3dc63e3f59b9d42a3dead22 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 19 May 2010 11:54:31 +0100 Subject: [PATCH] timers: Migrate timers away from an offlined CPU. Signed-off-by: Keir Fraser --- xen/common/timer.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/xen/common/timer.c b/xen/common/timer.c index 57d488ce9a..68b56a6805 100644 --- a/xen/common/timer.c +++ b/xen/common/timer.c @@ -515,6 +515,29 @@ static struct keyhandler dump_timerq_keyhandler = { .desc = "dump timer queues" }; +static void migrate_timers_from_cpu(unsigned int cpu) +{ + struct timers *ts; + struct timer *t; + + ASSERT((cpu != 0) && cpu_online(0)); + + ts = &per_cpu(timers, cpu); + + spin_lock_irq(&per_cpu(timers, 0).lock); + spin_lock(&ts->lock); + + while ( (t = GET_HEAP_SIZE(ts->heap) ? ts->heap[1] : ts->list) != NULL ) + { + remove_entry(ts, t); + t->cpu = 0; + __add_timer(t); + } + + spin_unlock(&ts->lock); + spin_unlock_irq(&per_cpu(timers, 0).lock); +} + static struct timer *dummy_heap; static int cpu_callback( @@ -531,8 +554,7 @@ static int cpu_callback( break; case CPU_UP_CANCELED: case CPU_DEAD: - /* Enable this later. */ - /*WARN_ON(GET_HEAP_SIZE(ts->heap) || ts->list);*/ + migrate_timers_from_cpu(cpu); break; default: break; -- 2.30.2